import { defineStore } from 'pinia'

import { getUserInfo } from '@/api/login'

const useUserstore = defineStore('user', {
  state() {
    return {
      userIfo: null as UserInfo | null,
      role: null as any | null,
    }
  },
  actions: {
    async getUserInfo() {
      const { userInfo, roles } = await getUserInfo()
      console.log(userInfo, roles)
      this.userIfo = userInfo
      this.role = roles
    },
  },
})

export default useUserstore
